package huawei;
/*
* @Author: wanghongfucoder
* @Date:   2017-06-28 13:53:00
* @Last Modified by:   wanghongfucoder
* @Last Modified time: 2017-06-28 13:55:01
*/

import java.util.Scanner;
 
/*题目描述
问题描述：给出4个1-10的数字，通过加减乘除，得到数字为24就算胜利
输入：
4个1-10的数字。[数字允许重复，测试用例保证无异常数字]
输出：
true or false*/
public class Pokergame {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double num = 0.0;
        while(sc.hasNextInt()){
            int[] initNums = new int[4];
            int[] temp = new int[4];
            for (int i = 0; i < initNums.length; i++) {
                initNums[i] = sc.nextInt();
            }
            System.out.println(check(initNums,temp, num));
        }
        sc.close();
    }
     
    public static boolean check(int[] initNums,int[] temp,double num){
        for (int i = 0; i < initNums.length; i++) {
            if (temp[i]==0) {
                temp[i] = 1;
                //System.out.println(num);
                if (check(initNums, temp,num + initNums[i])
                        || check(initNums,temp ,num - initNums[i])
                        || check(initNums,temp ,num * initNums[i])
                        || check(initNums, temp,num / initNums[i])) {
                    //System.out.println(num+".");
                    return true;
                }
                temp[i] = 0;
            }
        }
         if(num==24)
             return true;
         else
             return false;
    }
     
}